#!/bin/bash

# generate random IP address(es).
# number of IPs is piped to script OR specified as an argument. 

if [[ $# -eq 1  ]]
then
	if [[ $1 -eq "h" || $1 -eq "-h" ]]
	then
        	echo "usage: $0 <number>"
        	exit 1 
	fi

	for((i=0;i<$1;++i))
	do
	        a=$RANDOM; b=$RANDOM; c=$RANDOM; d=$RANDOM
        	let "a %= 255"; let "b %= 255 "; let "c %= 255 "; let "d %= 255"

        	echo $a.$b.$c.$d
		done
else
	read CYCLES

	for ((I = 1; I <= $CYCLES; I++))
	do
		W=$(($RANDOM % 255))
		X=$(($RANDOM % 255))
		Y=$(($RANDOM % 255))
		Z=$(($RANDOM % 255))

		echo $W.$X.$Y.$Z
	done
fi
